<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GSM-R空口监测系统-登录界面</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.4.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/jquery-easyui-1.4.4/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
	var baseURL = "http://localhost:8080/gsmr";
	function submitData(){
		/*
		var name = $("#userName").val();
		var pwd = $("#password").val();
		var database = $("#database").combobox('options');
		console.log(database);
		
		$.getJSON("http://192.168.1.113:8080/gsmr/user/login.do?userName="+name+"&password="+pwd+"&database=gly", function(result) {
			console.log(result);
			if (result.success) {
				var a = $('#database').combobox('getText');
				window.location.href="http://192.168.1.113:8080/gsmr/main.jsp?database=" +a;
			} else {
				$.messager.alert("系统提示",result.errorInfo);
			}
		});
*/
		
		$("#fm").form("submit",{
			url:"${pageContext.request.contextPath}/user/login.do",
			onSubmit:function(){
				return $(this).form("validate");
			},
			success:function(result){
				var a = $('#database').combobox('getText');
				var result=eval('('+result+')');
				if(result.success){
					window.location.href="${pageContext.request.contextPath}/main.jsp?database=" +a;
				}else{
					$.messager.alert("系统提示",result.errorInfo);
					return;
				}
			}
		 });
	}
	
	function resetValue(){
		$("#userName").val("");
		$("#password").val("");
		$("#groupId").combobox("setValue","");
	}
	
	
	var list = [];
	$.post("${pageContext.request.contextPath}/serverState/getServerId.do", function(result) {
		
		list = result;
	}, "json");
	
	
	$(function(){
		
		
		$("#database").combobox({
			onChange: function(n, o) {
				console.log(n);
				console.log(list);
				if (list.length < 1 || list[0].id == n) return;
				for (var i = 0; i < list.length; i++) {
					if (n == list[i].id) {
						baseURL = "http:" + list[i].url + ":8080/gsmr";
						break;
					}
				}
				console.log(baseURL);
				window.location.href=baseURL + "/login.jsp";
			}
		});
		
		
		
	});
	
	
	
	
	
	
	/*
	$.post("${pageContext.request.contextPath}/serverState/getServerId.do", function(result) {
		console.log(result);
		
	}, "json");
	*/
	
</script>
</head>
<body>
 <%!//在这种标记中定义的变量为全局变量    
	int count=0;    
	synchronized void count(){    
		count++; 
	}   
%>
<%count();%>
<p id="welcome" style="font-weight:bold">欢迎登陆GSM-R空口监测系统</p>
<!-- <p id="welcome" style="font-weight:bold"> 欢迎使用列车轨迹可视化系统</p> -->
<div style="position:absolute; width:100%; height:100%; z-index:-1; left:0; top:0;">      
	<img src="${pageContext.request.contextPath}/static/images/login_bg.jpg" height="100%" width="100%" style="left:0; top:0;">      
</div>  
<div class="easyui-window" title="GSM-R空口监测系统" data-options="modal:true,closable:false,minimizable:false,maximizable:false,collapsible:false" style="width:400px;height:300px;padding:10px;">
	<form id="fm" action="" method="get">
		<table cellpadding="6px" align="center">
			<tr align="center">
				<th colspan="2" style="padding-bottom: 10px"><big>用户登录</big></th>
			</tr>
			<br>
			<tr>
				<td>用户名：</td>
				<td><input type="text" id="userName" name="userName" class="easyui-validatebox" required="true" style="width: 200px"/></td>
			</tr>
			<tr></tr><tr></tr><tr></tr>
			<tr>
				<td>密码：</td>
				<td><input type="password" id="password" name="password" class="easyui-validatebox" required="true" style="width: 200px"/></td>
			</tr>
			<tr></tr><tr></tr><tr></tr>
			<!-- <tr>
				<td>角色：</td>
				<td><input class="easyui-combobox" id="groupId" name="groupId" data-options="panelHeight:'auto',valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/group/groupComboList.do'" value="gly"/></td>
			</tr> -->
			<tr>
				<td>线路：</td>
				<!--
				<td><input class="easyui-combobox" id="database" name="database" data-options="panelHeight:'auto',valueField:'lable',textField:'value', data:[
					    {lable:'dataSource1', value:'广深港线路'},
					    {lable:'dataSource2', value:'广深线路'},
					    {lable:'dataSource3', value:'测试线路'}]" required="true" style="width: 200px" value="dataSource1"/></td>
				-->
				<!--
				<td><input class="easyui-combobox" id="database" name="database" data-options="panelHeight:'auto',valueField:'lable',textField:'value', data:[
					    {lable:'dataSource1', value:'京沈线'},
					    {lable:'dataSource2', value:'哈大线'}]" required="true" style="width: 200px" value="dataSource1"/></td>
				-->
				<td><input class="easyui-combobox" id="database" name="database" data-options="panelHeight:'auto',
				valueField:'id',
				textField:'name',
				url:'${pageContext.request.contextPath}/serverState/getServerId.do'"  required="true"  style="width: 200px"/></td>
				
			</tr>
			<tr></tr><tr></tr><tr></tr>
			<tr>
				<td colspan="2"></td>
			</tr>
			
			<tr>
				<td></td>
				<td>
					<a href="javascript:submitData()" class="easyui-linkbutton" iconCls="icon-submit">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="javascript:resetValue()" class="easyui-linkbutton" iconCls="icon-reset">重置</a>
				</td>
			</tr>
		</table>
	</form>
</div>

</body>
</html>